<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <h1>原料库库存总览明细查询</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group">
                                    <label>统计类型</label>
                                    <select id="type" name="type" class="form-control">
                                        <option value="钢材总重量" th:selected="${type == '钢材总重量'}">钢材总重量</option>
                                        <option value="库存板材量" th:selected="${type == '库存板材量'}">库存板材量</option>
                                        <option value="库存型材量" th:selected="${type == '库存型材量'}">库存型材量</option>
                                        <option value="常用备件量" th:selected="${type == '常用备件量'}">常用备件量</option>
                                        <option value="项目总重量" th:selected="${type == '项目总重量'}">项目总重量</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>项目编号</label>
                                    <input type="text" name="ityProCode"
                                           class="form-control"
                                           placeholder="请输入项目编号"  th:value="${projectCode}">
                                </div>
                                <div class="form-group">
                                    <label>项目名称</label>
                                    <input type="text" name="ityProName"
                                           class="form-control"
                                           placeholder="请输入项目名称">
                                </div>
                                <div class="form-group">
                                    <label>跟踪号</label>
                                    <input type="text" name="ityTrackCode" class="form-control"
                                           placeholder="请输入跟踪号">
                                </div>
                                <div class="form-group">
                                    <label>原料类型</label>
                                    <input type="text" name="matTypeName" class="form-control"
                                           placeholder="请输入原料类型">
                                </div>
                                <div class="form-group">
                                    <label>原料材质</label>
                                    <input type="text" name="matQualityName" class="form-control"
                                           placeholder="请输入原料材质">
                                </div>
                                <div class="form-group">
                                    <label>原料规格</label>
                                    <input type="text" name="matSpecName" class="form-control"
                                           placeholder="请输入原料规格">
                                </div>
                                <div class="form-group">
                                    <label>宽度</label>
                                    <input type="number" step="0.1" name="matWidth"
                                           class="form-control"
                                           placeholder="请输入原料宽度">
                                </div>
                                <div class="form-group">
                                    <label>长度</label>
                                    <input type="number" step="0.1" name="matLength"
                                           class="form-control"
                                           placeholder="请输入原料长度">
                                </div>
                                <div class="form-group">
                                    <label>米重/厚度</label>
                                    <input type="number" step="0.1" name="matHeight"
                                           class="form-control"
                                           placeholder="请输入原料米重/厚度">
                                </div>
                                <!--<div class="form-group">
                                    <label>在库类型</label>
                                    <select name="ityInType" class="form-control">
                                        <option value="1" th:selected="${ityInType == 1}">库存在库</option>
                                        <option value="2" th:selected="${ityInType == 2}">项目在库</option>
                                        <option value="" th:selected="${ityInType == ''}">全部</option>

                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>
                                        原料分类
                                    </label>
                                    <select name="materialKind" class="form-control ">
                                        <option value="型材">型材&nbsp;&nbsp;</option>
                                        <option value="板材">板材&nbsp;&nbsp;</option>
                                        <option value="" selected="selected">全部</option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>仓库</label>
                                    <select class="form-control" name="whiId">
                                        <option value="">请选择</option>
                                        <option th:each="type:${warehouse}" th:value="${type.whiId}"
                                                th:text="${type.whiName}"
                                                th:selected="${type.whiName eq '原料库'}"></option>
                                    </select>
                                </div>-->
                                <button type="button" class="btn btn-success" id="btn-search">
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="row" id="toolbar">
                    <div class="form-inline">
                        <button type="button" id="btn_exportExcel" shiro:hasPermission="matinv:matinvquery:view" class="btn btn-primary">
                            导出
                        </button>
                        <img th:src="@{/img/downloadding.gif}" id="btn_tips" style="display: none"/>
                    </div>
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var table;

    $(function () {
        /**
         * 加载列表
         */
        table = js.table.init({
            url: ctx + "matInvManage/complex/index",
            pageSize: 300,
            showColumns: true,
            showExport: false,
            columns: [
                {
                    title: '序号', field: 'odaId', width: '50',
                    formatter: function (value, row, index) {
                        return index + 1;
                    }
                },
                {title: '类型', field: 'matTypeName', width: '90'},
                {title: '材质', field: 'matQualityName', width: '90'},
                {title: '规格', field: 'matSpecName', width: '90'},
                {title: '宽度', field: 'matWidth', width: '70'},
                {title: '长度', field: 'matLength', width: '70'},
                {title: '米重/<br>厚度', field: 'matHeight', width: '70'},
                {title: '数量', field: 'ityNum', width: '70'},
                {
                    title: '单价<br>（元）', field: 'ityPrice', width: '90',
                    formatter: function (value, row, index) {
                        if (hasP("matinv:amount:view")) {
                            if (value == undefined || value == null || value == 0) {
                                return "--"
                            } else {
                                return value;
                            }
                        } else {
                            return '***';
                        }
                    }
                },
                {
                    title: '金额<br>（元）', field: 'ityAmount', width: '100',
                    formatter: function (value, row, index) {
                        if (hasP("matinv:amount:view")) {
                            if (value == undefined || value == null || value == 0) {
                                return "--"
                            } else {
                                return value;
                            }
                        } else {
                            return '***';
                        }
                    }
                },
                {title: '理论重量', field: 'ityWeight', width: '100'},
                {title: '跟踪号', field: 'ityTrackCode', width: '110'},
                {title: '特殊说明', field: 'itySpec', width: '75'},
                {title: '项目编号', field: 'ityProCode', width: '95'},
                {title: '项目名称', field: 'ityProName', width: '300'},
                {title: '回货时间', field: 'ityBackDate', width: '110'},
                {
                    title: '在库类型', field: 'ityInType', width: '95',
                    formatter: function (value, row, index) {
                        if (value === 1) {
                            return '库存在库';
                        } else if (value === 2) {
                            return '项目在库';
                        }
                    }
                },
                {title: '库位', field: 'stockName', width: '80'}
            ],
            /*onLoadSuccess: function () {
                if (!hasP("matinv:amount:view")) {
                    table.bootstrapTable('hideColumn', 'ityPrice');
                    table.bootstrapTable('hideColumn', 'ityAmount');
                }
            },*/
            rowStyle: function (row, index) {
                if (row.itySpec != null && row.itySpec.indexOf("不合格") >= 0) {
                    return {css: {"color": "red"}}
                } else {
                    return {css: {"color": "black"}}
                }
            }
        });

        /** 表格搜索 */
        $("#btn-search").click(function () {
            js.table.search(table);
        });

        /**
         * 导出Excel
         */
        $("#btn_exportExcel").click(function () {
            $("#btn_exportExcel").hide();
            $("#btn_tips").show();
            js.post({
                url: ctx + "matInvManage/complex/exportExcel",
                data: $("#queryForm").serialize(),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        location.href=ctx + "purWarQuery/downloadExportExcel/"+result.data;
                    } else {
                        js.modal.warning("导出失败，请联系管理员！");
                    }
                    $("#btn_tips").hide();
                    $("#btn_exportExcel").show();
                }
            })
        });

    });
</script>
</body>
</html>
